﻿Chenxin.UI.DeductManage = Chenxin.extend(Chenxin.UI.PageCommon, {
    autoInitForm: false,
    actionUrl: '/service/logic/DeductManage.ashx',
    createSearch: function() {
        return new Chenxin.UI.DeductManageSearch({
            scope: this
        });
    },
    createGrid: function() {
        return new Chenxin.UI.MultiRowGrid({
            actionUrl: this.actionUrl + '?op=getlist',
            pageSize: 100,
            hasPage: true,
            cellBorder: true,
            height: 400,
            autoLoad: false,
            renderTo: 'DeductManage_table',
            hasCheckBox: false,
            id: 'searchtable',
            title: '抵扣记录',
            scope: this,
            columns: {
                ContractCode: {
                    width: 130,
                    head: '合同编号',
                    sortable: true,
                    sortField: "b.ContractCode"
                },
                HouseAddress: {
                    width: 300,
                    head: '房源地址',
                    sortable: true,
                    sortField: "b.HouseAddress"
                },
                PayMoney: {
                    width: 120,
                    head: '实收金额'
                },
                PreDeductMoney: {
                    width: 120,
                    head: '抵扣金额'
                },
                PreDeductType: {
                    width: 120,
                    head: '抵扣类型',
                    sortable: true,
                    renderer: function(val, field, row) {
                        if (val == 10) {
                            return '咨询费';
                        }
                        else if (val == 20) {
                            return '固定扣除';
                        }
                        else {
                            return '';
                        }
                    }
                },
                PayArchDate: {
                    width: 120,
                    head: '抵扣时间',
                    sortable: true,
                    sortField: "a.PayArchDate",
                    renderer: function(val, field, row) {
                        if (val.length > 0) {
                            return val.split('.')[0] + '年' + val.split('.')[1] + '月';
                        }
                        else {
                            return '';
                        }
                    }
                },
                StanCommision: {
                    width: 120,
                    items: {
                        VStanCommision: {
                            width: 120,
                            head: '上家标准佣金'
                        },
                        BStanCommision: {
                            width: 120,
                            head: '下家标准佣金'
                        }
                    }
                },
                RealCommisionFinal: {
                    width: 120,
                    items: {
                        VRealCommisionFinal: {
                            width: 120,
                            head: '上家确认佣金'
                        },
                        BRealCommisionFinal: {
                            width: 120,
                            head: '下家确认佣金'
                        }
                    }
                },
                CommisionFinal: {
                    width: 120,
                    items: {
                        VCommisionFinal: {
                            width: 120,
                            head: '上家折佣'
                        },
                        BCommisionFinal: {
                            width: 120,
                            head: '下家折佣'
                        }
                    }
                },
                ConsultingFinal: {
                    width: 120,
                    items: {
                        VConsultingFinal: {
                            width: 120,
                            head: '上家咨询费'
                        },
                        BConsultingFinal: {
                            width: 120,
                            head: '下家咨询费'
                        }
                    }
                }
            }
        });
    },
    initComponent: function() {
        Chenxin.UI.DeductManage.superclass.initComponent.call(this);
    }
});

/**
*查询面板
*/
Chenxin.UI.DeductManageSearch = Chenxin.extend(Chenxin.UI.SearchCommon, {
    id: 'DeductManage_search',
    initEvent: function() {
        var _this = this;

        //查询按钮
        $('#btnSreach').click(function() {
            _this.scope.reloadGrid("",0);
        });
        //抵扣日期
        $("#txttime").focus(function() {
            WdatePicker({
                dateFmt: 'yyyy.MM',
                oncleared: function() {
                    $(this).blur();
                },
                onpicked: function() {
                    $(this).blur();
                }
            });
        });

        //关键字
        $('#txtkeyword').defText({
            deftxt: '输入成交编号/地址'
        });
        
        var curdate = new Date();
        $('#txttime').val(curdate.getFullYear() + '.' + (curdate.getMonth() + 1));
    },
    createComboList: function() {

        //用户操作日志类型
        var cmbtype = new Chenxin.UI.Combo({
            containerId: '#divType',
            name: 'type',
            tbxWidth: 65,
            items: [{ val: '10', txt: '咨询费' }, { val: '20', txt: '固定扣除'}]
        }); 

        return [cmbtype];
    },
    initComponent: function() {
        Chenxin.UI.DeductManageSearch.superclass.initComponent.call(this);
    }
});

$(document).ready(function() {
    this.DeductManage = new Chenxin.UI.DeductManage();
});